<template>
  <div class="app-container">
    <el-row :gutter="15">
      <el-form ref="formRef" :model="formData" :rules="rules" size="default" label-width="100px">
        <el-col :span="24">
          <el-row gutter="16">
            <el-col :span="8">
              <el-form-item label="课程编号" prop="id">
                <el-input v-model="formData.id" type="text" placeholder="请输入课程编号" clearable
                  :style="{width: '100%'}"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item label="课程名称" prop="course_name">
                <el-input v-model="formData.course_name" type="text" placeholder="请输入课程名称" clearable
                  :style="{width: '100%'}"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="20">
          <el-row gutter="70">
            <el-col :span="22">
              <el-form-item label="课程描述" prop="course_description">
                <el-input v-model="formData.course_description" type="textarea" placeholder="请输入课程描述"
                  :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="24">
          <el-form-item>
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script setup>
const {
  proxy
} = getCurrentInstance()
const formRef = ref()
const data = reactive({
  formData: {
    id: undefined,
    course_name: undefined,
    course_description: undefined,
  },
  rules: {
    id: [{
      required: true,
      message: '请输入课程编号',
      trigger: 'blur'
    }],
    course_name: [{
      required: true,
      message: '请输入课程名称',
      trigger: 'blur'
    }],
    course_description: [{
      required: true,
      message: '请输入课程描述',
      trigger: 'blur'
    }],
  }
})
const {
  formData,
  rules
} = toRefs(data)
/**
 * @name: 表单提交
 * @description: 表单提交方法
 * @return {*}
 */
function submitForm() {
  formRef.value.validate((valid) => {
    if (!valid) return
    // TODO 提交表单
  })
}
/**
 * @name: 表单重置
 * @description: 表单重置方法
 * @return {*}
 */
function resetForm() {
  formRef.value.resetFields()
}

</script>
<style>
</style>
